<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
</head>
<body>
<div class="layui-fluid" style="padding: 15px;">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <div class="layui-col-md6 layui-col-xs6 layui-col-sm6">
                    <span>运单号:  </span><span id="bil-logistics-list-waybillNo"></span>

                </div>
                <div class="layui-col-md6 layui-col-xs6 layui-col-sm6">
                    <span>快递号:  </span><a href="javascript:;" id="bil-logistics-list-expressNo" target="_blank"></a>
                </div>
            </div>

            <table class="layui-hide" id="bil-logistics-list-table" lay-filter="bil-logistics-list-table"></table>
        </div>
    </div>
</div>

<script type="text/html" id="bil-logistics-table-state-tmp">
    【TD Cargo】 {{  d.description }}
</script>

<script src="/layui/layui.js"></script>
<script>
    layui.config({
        base: '/src/',
        version: new Date().getTime()
    }).extend({setter: "config", admin: "lib/admin", view: "lib/view"})
        .define(['setter', 'admin', 'table', "form"], function () {
            var $ = layui.$,
                admin = layui.admin,
                form = layui.form,
                table = layui.table;

            function getRequestParam(param) {
                var requestString = location.search;
                var reg = new RegExp("(?:\\?|&)" + param + "=(.*?)(?:&|$)");
                if (reg.test(requestString)) {
                    return decodeURIComponent(RegExp.$1);
                } else {
                    return '';
                }
            }

            admin.req({
                url: "/listBilLogistics",
                data: {waybillNo: getRequestParam("waybillNo")},
                beforeSend: function () {
                    layer.load(2, {time: 100 * 1000});
                },
                complete: function () {
                    layer.closeAll('loading');
                },
                done: function (res) {
                    var data = res.data;
                    if(data.length > 0) {
                        $("#bil-logistics-list-waybillNo").html(data[0].waybillNo ? data[0].waybillNo : "");
                        $("#bil-logistics-list-expressNo").html(data[0].expressNo ? data[0].expressNo : "");
                        if (data[0].expressNo) {
                            $("#bil-logistics-list-expressNo").attr("href", "http://m.kuaidi100.com/result.jsp?nu=" + data[0].expressNo);
                        }

                        table.render({
                            elem: '#bil-logistics-list-table',
                            cols: [[
                                {field: 'updateTime', title: '时间'},
                                {field: 'description', title: '进度', templet: "#bil-logistics-table-state-tmp"}
                            ]],
                            data: data
                        });
                    } else{
                        $("#bil-logistics-list-waybillNo").html("运单号不存在");
                    }
                }
            });
        });
</script>
</body>
</html>